package com.itheima.validation;

import com.itheima.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;


/**
 * @author panweiwei
 */
public class StateValidation implements ConstraintValidator<State, String> {
    /**
     * 校验规则
     *
     * @param s                          将来要效验的数据
     * @param constraintValidatorContext
     * @return 返回false 效验失败 true 成功
     */
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (s == null) {
            return false;
        }

        if (s.equals("已发布") | s.equals("草稿")) {
            return true;
        }
        return false;
    }
}
